package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealDao {
    @Insert("insert into t_setmeal(name,code,helpCode,sex,age,price,remark,attention,img) values(#{name},#{code},#{helpCode},#{sex},#{age},#{price},#{remark},#{attention},#{img})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    public int add(Setmeal setmeal);
     @Insert("insert into t_setmeal_checkgroup values(#{setmeal_id},#{checkgroupId})")
    void addSetmealAndcheckGroup(@Param("setmeal_id") int setmeal_id, @Param("checkgroupId") int checkgroupId);
    @Select("select * from t_setmeal where code like #{code} or name like #{name} or helpCode like #{helpCode} ")
    Page<Setmeal> findByPage(String queryString);
    @Select("select * from t_setmeal")
    List<Setmeal> findAll();
    @Select("select * from t_setmeal where id=#{id}")
    Setmeal findById(int id);

    @Select("select t2.* from t_setmeal_checkgroup t1,t_checkgroup t2 where t1.checkgroup_id = t2.id and t1.setmeal_id=#{id}")

    public List<CheckGroup> findsetmealAndcheckgroupById(int id);
     @Select("select number-reservations from t_ordersetting where orderDate =#{orderDate}")
    int isOrder(String orderDate);
}
